package controller

import (
	"context"
	"lot_admin_api/api"
	"lot_admin_api/internal/model"
	"lot_admin_api/internal/service"
)

var Staff = cStaff{}

type cStaff struct{}

// AddStaff  添加员工
func (h *cStaff) AddStaff(ctx context.Context, req *api.AddStaffReq) (res *model.StaffIdRes, err error) {
	saveId, err := service.Staff().AddStaff(ctx, req)
	res = &model.StaffIdRes{
		Id: saveId,
	}
	return res, err
}

// UpdateStaff  编辑员工
func (h *cStaff) UpdateStaff(ctx context.Context, req *api.UpdateStaffReq) (res *model.StaffIdRes, err error) {
	saveId, err := service.Staff().UpdateStaff(ctx, req)
	res = &model.StaffIdRes{
		Id: saveId,
	}
	return res, err
}

// DeleteStaff  删除员工
func (h *cStaff) DeleteStaff(ctx context.Context, req *api.DeleteStaffReq) (res *model.StaffIdRes, err error) {
	saveId, err := service.Staff().DeleteStaff(ctx, req)
	res = &model.StaffIdRes{
		Id: saveId,
	}
	return res, err
}

// AllocationStaff  调拨员工
func (h *cStaff) AllocationStaff(ctx context.Context, req *api.AllocationStaffReq) (res *model.StaffIdRes, err error) {
	allocationId, err := service.Staff().AllocationStaff(ctx, req)
	res = &model.StaffIdRes{
		Id: allocationId,
	}
	return res, err
}

// GetOneStaff  获取员工详情及其权限列表
func (h *cStaff) GetOneStaff(ctx context.Context, req *api.GetOneStaffReq) (res *model.StaffInfoRes, err error) {
	res, err = service.Staff().GetIdStaffInfo(ctx, req.Id)
	return res, err
}

// StaffList  通过搜索条件获取员工列表
func (h *cStaff) StaffList(ctx context.Context, req *api.StaffListReq) (res *model.StaffListPageRes, err error) {
	res, err = service.Staff().StaffList(ctx, req)
	return res, err
}
